package com.clc.controller.wallet;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.clc.bean.WalletAccount;
import com.clc.bean.WalletType;
import com.clc.service.IWalletService;


@Controller
@RequestMapping("/wallet")
public class WalletController {
	static Log log = LogFactory.getLog(WalletController.class.getName());
	@Autowired
	private IWalletService walletService;
	
	@RequestMapping(value="/income")
    public String excuteAction(Model model)  
    		 throws Exception {
		log.info("income");
		List<WalletAccount> accounts = walletService.findAccounts();
		List<WalletType> walletTypes = walletService.findAllWalletTypes();
		System.out.println("======================");
		for (WalletType walletType : walletTypes) {
			System.out.println(walletType.getTypeName());
			for (WalletType wallet : walletType.getWalletTypes()) {
				System.out.println(wallet.getTypeName());
			}
			System.out.println("--------------------");
		}
		log.info("==========accounts:"+accounts.size());
		log.info("==========walletTypes:"+walletTypes.size());
		model.addAttribute("accounts",accounts);
		model.addAttribute("walletTypes",walletTypes);
		return "wallet/income";
    } 

}
